function quickSort(arr=[]){
    let {length} = arr;
    if(length <= 1){
        return arr
    }
    let pivot = arr[0];
    let right =[];let left = [];
    for(let i = 1;i<length;i++){
        if(arr[i] > pivot){
            right.push(arr[i]);
        }else{
            left.push(arr[i]);
        }
    }

    let l = quickSort(left);

    let r = quickSort(right);

    return l.concat(pivot).concat(r)

}

console.log(quickSort([3,4,6,3,2,1]));